package com.dao.Impl;

import com.dao.FoodDao;
import com.pojo.Callfood;
import com.pojo.Food;

import java.util.List;

public class FoodImpl extends BaseDao implements FoodDao {

    @Override
    public int addFood(Food food) {
        String sql="insert into t_food  (name,price,cate,imgpath) values  (?,?,?,?)";
        return update(sql,food.getName(),food.getPrice(),food.getCate(),food.getImgpath());
}

    @Override
    public int deleteFoodById(Integer id) {
        String sql="delete from t_food where id=?";
        return update(sql,id);
    }

    @Override
    public Food queryBookById(Integer id) {
        String sql="select id,name,price,cate,imgpath from t_food where id=?";
        return queryForOne(Food.class,sql,id);
    }

    @Override
    public List<Food> queryFoods() {
        String sql="select id,name,price,cate,imgpath from t_food";
        return queryForList(Food.class,sql);
    }
    @Override
    public List<Food> querylsFoods(String cate) {
        String sql="select id,name,price,cate,imgpath from t_food where cate=?" ;
        return queryForList(Food.class,sql,cate);
    }



    @Override
    public int callFood(Callfood callfood) {
        String sql="insert into t_callfood  (time,sushehao,foodname) values  (?,?,?)";
        return update(sql,callfood.getTime(),callfood.getSushehao(),callfood.getFoodname());
    }

    @Override
    public List<Callfood> queryCallFoods() {
        String sql="select time,sushehao,foodname from t_callfood";
        return queryForList(Callfood.class,sql);
    }
}
